<template>
  <right>
    <template slot="card">
      <CardGroup ref="cardGr" :currentTabType="currentTabType"></CardGroup>
    </template>
    <template slot="detail">
      <transition name="fade" mode="out-in" >
        <router-view>
        </router-view>
      </transition>
    </template>
  </right>
</template>
<script>
  import right from '@/components/ui-modules/right-layout/RightLayout'
  import CardGroup from './EmailCardGroup.vue'
  export default {
    name: 'Email',
    data () {
      return {
        currentRoute: ''
      }
    },
    beforeRouteLeave (to, from, next) {
      this.currentRoute = from.fullPath
      next()
    },
    beforeRouteEnter (to, from, next) {
      next(vm => {
        if (to.query.active) {
          // 从其他模块push路由
        } else if (to.fullPath.indexOf('email_todo') > -1) {
//          邮件提醒&&重复提醒，路由跳转，to.query中没有active，所以才进行此操作
        } else if (vm.currentRoute) {
          vm.$router.push({path: vm.currentRoute})
          vm.$refs.cardGr.routerEnter()
        } else if (!vm.currentRoute) {
          vm.$store.commit('BLANK', 'email_todo')
        }
      })
    },
    watch: {
      $route (to, from) {
//        let fromArr = from.path.split('/')
        let toArr = to.path.split('/')
        if (toArr[2] === 'email') {

        }
      }
    },
    components: {
      right,
      CardGroup
    },
    methods: {
      routeChange (tabType) {
        this.tabType = tabType
      }
    },
    computed: {
      currentTabType () {
        return this.tabType
      }
    }
  }
</script>
<style lang="stylus" scoped>
.call
  background #efefef
  color $cf-level2
li
  width 439px
  height 79px
  border-bottom 1px solid #eee
.cust-info
  min-height 141px
  max-width 200px
  width 100%
.cust-tab
  height:100%
</style>
